<?php
include_once("../func/getYsave.php");
session_start();
if(!isset($_SESSION['username'])){
	echo '<script type="text/javascript">alert("请登录");
	window.location.href = \'../login.html\';</script>';
}
include_once("../conn.php");
$field=$_POST['id'];
$val=$_POST['value'];
$xh = getXh($field);
$zd = strtok($field,"2");
$v = getYxg($field);
$val = htmlspecialchars($val, ENT_QUOTES);
//本科生
if($xh[4]=="1"){
if($val=="0"||$val=="1"){
	$index = mysql_query("select rank from bkzd where zd='$zd'");
	if($row=mysql_fetch_array($index))
	{
		$i=$row["rank"];
		$v[(int)$i-2] = $val;
		$query=mysql_query("update bachelor set yxg='$v',xg=1 where xh=$xh");
		if($query){
	   echo $val;
	}else{
	   echo "修改失败";	
	}
	}
	
}else{
	echo "数据类型错误";
}
}
//研究生
if($xh[4]=="2"){
if($val=="0"||$val=="1"){
	$index = mysql_query("select rank from yjszd where zd='$zd'");
	if($row=mysql_fetch_array($index))
	{
		$i=$row["rank"];
		$v[(int)$i-2] = $val;
		$query=mysql_query("update master set yxg='$v',xg=1 where xh=$xh");
		if($query){
	   echo $val;
	}else{
	   echo "修改失败";	
	}
	}
	
}else{
	echo "数据类型错误";
}
}
//博士生
if($xh[4]=="3"){
if($val=="0"||$val=="1"){
	$index = mysql_query("select rank from bsszd where zd='$zd'");
	if($row=mysql_fetch_array($index))
	{
		$i=$row["rank"];
		$v[(int)$i-2] = $val;
		$query=mysql_query("update phd set yxg='$v',xg=1 where xh=$xh");
		if($query){
	   echo $val;
	}else{
	   echo "修改失败";	
	}
	}
	
}else{
	echo "数据类型错误";
}
}